package com.example.demo.service;

import com.example.demo.entity.Product;
import com.example.demo.mapper.AboutOrderMapper;
import com.example.demo.model.PageBean;
import com.example.demo.model.Result;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

@Service
@AllArgsConstructor
public class AboutOrderService {
    private AboutOrderMapper aboutOrderMapper;

    public Result getAllOrderHead(Integer current, Integer pageSize) {
        Page<Product> page = PageHelper.startPage(current, pageSize);
        aboutOrderMapper.getAllOrderHead();
        PageBean<Product> pageBean = new PageBean<>();
        pageBean.setData(page.getResult());
        pageBean.setTotal(page.getTotal());
        pageBean.setCurrent(page.getPageNum());

        return Result.buildSuccess(pageBean);
    }
}
